#include "Splines.h"

class Fun : public Function
{
public:
    double f(double x) {return 1/(1+x*x);}
    double df(double x) {return -2*x/(1+x*x)/(1+x*x);}
    double ddf(double x) {return (6*x*x-2)/(1+x*x)/(1+x*x)/(1+x*x);}
};

int main(int argc, char * argv[])
{
    double m;
    vector<double> x,y,z,t;
    double a[7]={-3.5,-3.0,-0.5,0.0,0.5,3.0,3.5};
    Fun g;
    Splines s;
    for(int i=1;i<=11;i++)
    {
        m = -6+i;
        x.push_back(m);
        y.push_back(g.f(m));
    }
    s = interpolation(x,y,g.df(-5),g.df(5),g.ddf(-5),g.ddf(5),"Bsplines","cubic","ccs");
    s.fileprintspline("dataC.txt");
    pushback(z,a,7);
    for(int i=0;i<7;i++)
    {
        m = fabs(g.f(z[i])-s.value(z[i]));
        t.push_back(m);
    }
    printvector(t);
}